//
// Unihan Input Method
//
// Copyright © 2002-2007 Sun Wah Linux Ltd.
//
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
// USA
//
// $Id: upimdpref_cb.c 757 2007-05-10 08:19:31Z roger $
//

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gnome.h>
#include <glade/glade.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
#include "prefedit.h"
#include "upimdpref_cb.h"
#include "unihan-gconf.h"


GConfClient* client;

void
data_init(void)
{
	client = gconf_client_get_default();
	

	inputstyle =  (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key1",NULL);
	letter_select_lookup = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key2",NULL);
	double_pin_input = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key3",NULL);
	double_pin_showInfo = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key4",NULL);
	cursor_follow = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key5",NULL);
	dynamic_adjust_phrasefeq = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key6",NULL);
	autohide_lowfeqword = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key7",NULL);
	dynamic_adjust_wordfeq = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key8",NULL);
	lately_inputword_first = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key9",NULL);
	candidateword_num = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key10",NULL);
	ch_en_switchkey = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key11",NULL);
	enter_define = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key12",NULL);
	multicandidate_pagekey = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key13",NULL);
	input_No23_candidatekey = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key14",NULL);
	phrase_define_wordkey = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key15",NULL);
	softkeyboard_key = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key16",NULL);
	GBK_support = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key17",NULL);
	simplify_chinese = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key18",NULL);
	itphrase = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key19",NULL);
	itphrase_automind = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key20",NULL);
	autoadjust_wordorder = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key21",NULL);
	digit_follow_letter = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key22",NULL);
	store_latelyinput_word = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key23",NULL);
	shengmu_customize = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key24",NULL);
	yunmu_customize = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key25",NULL);
	softkeyboard_index = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key26",NULL);
	chinese_symbol = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key27",NULL);
	english_default = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key28",NULL);
	vstate_space = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key29",NULL);
	most_chinese_num = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key30",NULL);
	double_pin_strategy = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key31",NULL);
	use_mohuyin = (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key33",NULL);

}	

void
on_radiobutton3_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	
	double_pin_input = 0;
	w = glade_xml_get_widget(xml, "comboboxentry6");
	gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
	w = glade_xml_get_widget(xml, "checkbutton24");
	gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
}


void
on_radiobutton2_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	
	inputstyle = 1;
	w = glade_xml_get_widget(xml, "checkbutton20");
	gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
}


void
on_radiobutton1_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	
	inputstyle = 0;
	w = glade_xml_get_widget(xml, "checkbutton20");
	gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE);
}


void
on_radiobutton4_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	
	double_pin_input = 1;
	w = glade_xml_get_widget(xml, "comboboxentry6");
	gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE);
	w = glade_xml_get_widget(xml, "checkbutton24");
	gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE);
}


void
on_checkbutton1_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	
	if(dynamic_adjust_phrasefeq)
		dynamic_adjust_phrasefeq = 0;
	else
		dynamic_adjust_phrasefeq = 1;
	
}


void
on_checkbutton2_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(dynamic_adjust_wordfeq)
		dynamic_adjust_wordfeq = 0;
	else
		dynamic_adjust_wordfeq = 1;
}


void
on_checkbutton3_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(lately_inputword_first)
		lately_inputword_first = 0;
	else
		lately_inputword_first = 1;
}


void
on_comboboxentry1_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{
	gint idx;

	//idx = gtk_combo_box_entry_get_text_column(combobox);
	idx = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
	candidateword_num = idx + 3;
	
}


void
on_radiobutton5_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	ch_en_switchkey = 0;
}


void
on_radiobutton6_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	ch_en_switchkey = 1;
}


void
on_comboboxentry2_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{
    multicandidate_pagekey = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
		
}


void
on_comboboxentry3_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{

    phrase_define_wordkey = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));

}


void
on_comboboxentry4_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{

	enter_define = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));

}


void
on_comboboxentry5_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{
	gint idx;

	idx = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
	softkeyboard_key = idx + 'a';
    
}

void
on_comboboxentry6_changed              (GtkComboBoxEntry     *combobox,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	GtkTextBuffer *buf1;
	GtkTextIter iter;
		
	double_pin_strategy = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
    
    w = glade_xml_get_widget(xml, "textview1");
    
    
    buf1 = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
    
    gtk_text_buffer_set_text(buf1,"",-1);
    
    gtk_text_buffer_get_end_iter(buf1,&iter);
 	//gtk_text_buffer_insert(buf1,&iter,"声母        韵母        零声母音节的韵母\n",-1);    
       // gtk_text_buffer_insert(buf1,&iter,"声母\n",-1); 
	//gtk_text_buffer_insert(buf1,&iter,"声母        韵母        零声母音节的韵母\n",-1); 
	//gtk_text_buffer_insert(buf1,&iter,"声母        韵母        零声母音节的韵母\n",-1); 
	
    if(double_pin_strategy == 2)
    {
 		gtk_text_buffer_get_end_iter(buf1,&iter);
 		//gtk_text_buffer_insert(buf1,&iter,"ch = U      ai = S   a = AA\n",-1);
 		gtk_text_buffer_insert(buf1,&iter,"紫光拼音输入法  双拼编码方案\n\n兼容微软拼音输入法双拼方案\n\n双拼编码将在输入法下次使用双拼时启用。\n\n[声母]\nch=U\nsh=I\nzh=V\n\n[韵母]\nai=S\nan=F\nang=G\nao=D\nei=W\nen=R\neng=T\ner=Q\nia=B\nian=J\niang=H\niao=K\nie=M\nin=L\ning=Q\niong=Y\niu=N\nong=Y\nou=P\nua=B\nuai=X\nuan=C\nuai=X\nuan=C\nuang=H\nue=X\nui=V\nun=Z\nuo=O\n\n[零声母音节的韵母]\na=AA\ne=EE\no=OO\n",-1);
		gtk_text_buffer_get_end_iter(buf1,&iter); 

    	    	
    }else if(double_pin_strategy == 1)
    {
 		gtk_text_buffer_get_end_iter(buf1,&iter);
 		gtk_text_buffer_insert(buf1,&iter,"紫光拼音输入法  双拼编码方案\n\n兼容中文之星新双拼方案\n\n双拼编码将在输入法下次使用双拼时启用.\n\n[声母]\nch=I\nsh=U\nzh=V\n\n[韵母]\nai=L\nan=J\nang=H\nao=K\nei=Z\nen=F\neng=G\ner=R\nia=W\nian=M\niang=D\niao=C\nie=X\nin=N\ning=;\niong=S\niu=Q\nong=S\nou=B\nua=W\nuai=Y\nuan=R\nuai=Y\nuan=R\nuang=D\nue=T\nui=V\nun=P\nuo=O\nv=y\nve=T\n\n[零声母音节的韵母]\na=OA\nai=OL\nan=OJ\nang=OH\nao=OK\ne=OE\nei=OZ\nen=OF\neng=OG\ner=OR\no=OO\nou=OB\n",-1);
		gtk_text_buffer_get_end_iter(buf1,&iter); 
		
    }else{
    	gtk_text_buffer_get_end_iter(buf1,&iter);
 		gtk_text_buffer_insert(buf1,&iter,"紫光拼音输入法  双拼编码方案\n\n  您可以按照以下格式来自定义双拼编码方案。\n以分号;打头的行是注释，不处理,韵母ve与ue等价。\n双拼编码范围为英文字母键(A到Z)和分号键“;”。\n在此文件中，为了看起来醒目起见，双拼编码采用大写英文字母；\n而在实际输入过程中，只能使用小写英文字母。\n\n[声母]\n双拼编码就是它本身的声母不必列出\nch=A\nsh=I\nzh=U\n\n[韵母]\n双拼编码就是它本身的韵母不必列出\nai=P\nan=R\nang=S\nao=Q\nei=K\nen=W\neng=T\ner=J\nia=X\nian=\niang=G\niao=B\nie=D\nin=Y\ning=C\ning=;\niong=H\niu=J\nong=H\nou=Z\nua=X\nuai=Y\nuan=L\nuang=G\nue=N\nve=N\nui=N\nun=\nuo=O\n\n[零声母音节的韵母]\n 在零声母音节情况下，韵母优先使用本节中的定义：本节中有定义时\n使用本节中的定义，本节中未定义时使用“韵母”节中的定义。\na=OA\nai=OP\nan=OR\nang=OS\nao=OQ\ne=OE\nei=OK\nen=OW\neng=OT\ner=OJ\no=OO\nou=OZ\n",-1);
 		gtk_text_buffer_get_end_iter(buf1,&iter); 
 		
} 


}

void
on_checkbutton11_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(yunmu_customize & 0x02)
		yunmu_customize &= 0xFD;
	else
		yunmu_customize |= 0x02;
}


void
on_checkbutton12_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(yunmu_customize & 0x04)
		yunmu_customize &= 0xFB;
	else
		yunmu_customize |= 0x04;
}


void
on_checkbutton13_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(yunmu_customize & 0x08)
		yunmu_customize &= 0xF7;
	else
		yunmu_customize |= 0x08;
}


void
on_checkbutton6_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x02)
		shengmu_customize &= 0xFD;
	else
		shengmu_customize |= 0x02;
}


void
on_checkbutton7_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x10)
		shengmu_customize &= 0xEF;
	else
		shengmu_customize |= 0x10;
}


void
on_checkbutton8_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x20)
		shengmu_customize &= 0xDF;
	else
		shengmu_customize |= 0x20;
}


void
on_checkbutton9_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x08)
		shengmu_customize &= 0xF7;
	else
		shengmu_customize |= 0x08;
}


void
on_checkbutton10_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(yunmu_customize & 0x01)
		yunmu_customize &= 0xFE;
	else
		yunmu_customize |= 0x01;
}


void
on_checkbutton14_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(yunmu_customize & 0x10)
		yunmu_customize &= 0xEF;
	else
		yunmu_customize |= 0x10;
}


void
on_checkbutton5_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x04)
		shengmu_customize &= 0xFB;
	else
		shengmu_customize |= 0x04;
}


void
on_checkbutton4_toggled                (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(shengmu_customize & 0x01)
		shengmu_customize &= 0xFE;
	else
		shengmu_customize |= 0x01;
}


void
on_checkbutton16_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(digit_follow_letter)
		digit_follow_letter = 0;
	else
		digit_follow_letter = 1;
}


void
on_checkbutton17_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(itphrase_automind)
		itphrase_automind = 0;
	else
		itphrase_automind = 1;
}


void
on_checkbutton19_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(store_latelyinput_word)
		store_latelyinput_word = 0;
	else
		store_latelyinput_word = 1;
}


void
on_checkbutton15_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(itphrase)
		itphrase = 0;
	else
		itphrase =1;
}


void
on_radiobutton9_toggled          (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GBK_support = 0;
}


void
on_radiobutton10_toggled         (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	GBK_support = 1;
}


void
on_radiobutton11_toggled         (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	simplify_chinese =1;
}


void
on_radiobutton12_toggled         (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{	
	simplify_chinese = 0;
}


void
on_radiobutton13_toggled         (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	english_default = 0;
}


void
on_radiobutton14_toggled         (GtkRadioButton  *radiobutton,
                                        gpointer         user_data)
{
	english_default = 1;
}


void
on_checkbutton18_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(autoadjust_wordorder)
		autoadjust_wordorder = 0;
	else
		autoadjust_wordorder = 1;
}

void
on_checkbutton20_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(letter_select_lookup)
		letter_select_lookup = 0;
	else
		letter_select_lookup = 1;
}

void
on_checkbutton21_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(autohide_lowfeqword)
		autohide_lowfeqword = 0;
	else
		autohide_lowfeqword = 1;
}

void
on_checkbutton22_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(cursor_follow)
		cursor_follow = 0;
	else
		cursor_follow = 1;
}

void
on_checkbutton23_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	if(vstate_space)
		vstate_space = 0;
	else
		vstate_space = 1;
}

void
on_checkbutton24_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{
	
}


void
on_checkbutton25_toggled               (GtkToggleButton *togglebutton,
                                        gpointer         user_data)
{	

	GtkWidget *w;
	GladeXML *xml_upimdpref = (GladeXML *)user_data;
	
	if(use_mohuyin)
	{
		use_mohuyin = 0;
		
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton4");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton5");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton6");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton7");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton8");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton9");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton10");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton11");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton12");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton13");
		gtk_widget_set_sensitive(w,FALSE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton14");
		gtk_widget_set_sensitive(w,FALSE);
	}else{
		use_mohuyin = 1;
		
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton4");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton5");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton6");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton7");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton8");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton9");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton10");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton11");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton12");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton13");
		gtk_widget_set_sensitive(w,TRUE);
		w = glade_xml_get_widget(xml_upimdpref, "checkbutton14");
		gtk_widget_set_sensitive(w,TRUE);
	}
	
}	


void
on_button1_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
	GError* err;
	
	if(!gnome_help_display ("zg.xml", NULL, &err))
    	printf("call gnoem_help_display failure:%s.\n", err->message);
}


void
on_button2_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	
	w = glade_xml_get_widget(xml, "windowupimdpref");
	g_object_unref(G_OBJECT(xml));
	gtk_widget_destroy(w);
}


void
on_button3_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
	GladeXML *xml = (GladeXML *)user_data;
	GtkWidget *w;
	GtkWidget* dialog;
	gchar *message;
	
	if(multicandidate_pagekey == phrase_define_wordkey)
	{
		message = "多个候选字词翻页键和以词定字选字键冲突.";
		dialog = gtk_message_dialog_new(NULL,
							GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
							GTK_MESSAGE_WARNING,
							GTK_BUTTONS_OK,
							message);
		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
		return;
	}
	/*else if(ch_en_switchkey == input_No23_candidatekey)
	{
		message = "中英文输入切换键和以输入第二第三候选字词键冲突.";
		dialog = gtk_message_dialog_new(NULL,
							GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
							GTK_MESSAGE_WARNING,
							GTK_BUTTONS_OK,
							message);
		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
		return;
	}*/
	
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key1",inputstyle, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key2",letter_select_lookup, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key3",double_pin_input, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key4",double_pin_showInfo, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key5",cursor_follow, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key6",dynamic_adjust_phrasefeq, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key7",autohide_lowfeqword, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key8",dynamic_adjust_wordfeq, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key9",lately_inputword_first, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key10",candidateword_num, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key11",ch_en_switchkey, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key12",enter_define, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key13",multicandidate_pagekey, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key14",input_No23_candidatekey, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key15",phrase_define_wordkey, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key16",softkeyboard_key, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key17",GBK_support, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key18",simplify_chinese, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key19",itphrase, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key20",itphrase_automind, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key21",autoadjust_wordorder, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key22",digit_follow_letter, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key23",store_latelyinput_word, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key24",shengmu_customize, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key25",yunmu_customize, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key26",softkeyboard_index, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key27",chinese_symbol, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key28",english_default, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key29",vstate_space, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key30",most_chinese_num, NULL);
	gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key33",use_mohuyin, NULL);
	
	if(double_pin_strategy == (int)gconf_client_get_int(client,"/apps/sw-unihan/gnome_aux/unispim/key31",NULL))
	{
		gconf_client_set_bool(client,"/apps/sw-unihan/gnome_aux/unispim/key32",FALSE,NULL);
	}else{	
		gconf_client_set_int(client, "/apps/sw-unihan/gnome_aux/unispim/key31",double_pin_strategy, NULL);
		gconf_client_set_bool(client,"/apps/sw-unihan/gnome_aux/unispim/key32",TRUE,NULL);
	}

	if(gconf_client_get_bool(client,PREFEDIT_UNISPIM_SET_KEY,NULL))
		gconf_client_set_bool(client,PREFEDIT_UNISPIM_SET_KEY,FALSE,NULL);
	else
		gconf_client_set_bool(client,PREFEDIT_UNISPIM_SET_KEY,TRUE,NULL);

	w = glade_xml_get_widget(xml, "windowupimdpref");
	g_object_unref(G_OBJECT(xml));
	gtk_widget_destroy(w);
}

void
on_upimdpref_Window_destroy(GtkWidget *widget, gpointer data)
{
	GladeXML *xml = (GladeXML *)data;
	g_object_unref(G_OBJECT(xml));
	gtk_widget_destroy(widget);
}



// vi:ts=4:nowrap:cin:expandtab
